/*
 * @Author: kadu
 * @Date: 2021-06-26 02:26:22
 * @LastEditTime: 2021-06-26 16:27:46
 * @LastEditors: Please set LastEditors
 * @Description: 配置数据系统，用来加载配置数据
 */
import { assetManager } from "cc";
import { BaseSystem } from "./BaseSystem";
import { ConfigEntity } from "./ConfigEntity";
import { Res } from "../res/Res";


export class ConfigSystem extends BaseSystem {
    protected async init() {
        var asset = await Res.loadJson("app_config"); // "app_config"
        if (!asset) {
            return;
        }

        (window as any).GameConfig = asset.json;
        assetManager.releaseAsset(asset);

        var asset = await Res.loadJson("config/config"); // "config/config"
        if (!asset) {
            return;
        }
        
        let datas: any = asset.json;
        let dataDict: any = {};
        for (let key in datas) {
            let data = datas[key];
            let config = new ConfigEntity(data);
            dataDict[key] = config
        }
        (window as any).DataCenter = dataDict;
        assetManager.releaseAsset(asset);

    }

}